//
//  NSTimer+Extension.m
//  TableDemo
//
//  Created by jutuo on 2020/3/25.
//  Copyright © 2020 jutuo. All rights reserved.
//

#import "NSTimer+Extension.h"


@implementation NSTimer (Extension)
+ (void)onTimer:(NSTimer *)timer
{
    void (^block)(NSTimer *timer) = timer.userInfo;
    
    if (block) {
        block(timer);
    }
}

+ (NSTimer *)scheduledTimerWithTimeInterval:(NSTimeInterval)interval repeat:(BOOL)repeats block:(void (^)(NSTimer *timer))block
{
    NSTimer *timer = [self scheduledTimerWithTimeInterval:interval target:self selector:@selector(onTimer:) userInfo:block repeats:repeats];
    return timer;
}

+ (NSTimer *)timerWithTimeInterval:(NSTimeInterval)interval repeat:(BOOL)repeats block:(void (^)(NSTimer * timer))block
{
    NSTimer *timer = [self timerWithTimeInterval:interval target:self selector:@selector(onTimer:) userInfo:block repeats:repeats];
    return timer;
}
@end
